package com.ylsk.check.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ylsk.check.domain.dto.ReportInfoDTO;
import com.ylsk.check.domain.so.ReportInfoSO;
import com.ylsk.check.domain.vo.ReportInfoVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ylsk.common.annotation.Log;
import com.ylsk.common.core.controller.BaseController;
import com.ylsk.common.core.domain.AjaxResult;
import com.ylsk.common.enums.BusinessType;
import com.ylsk.check.domain.ReportInfo;
import com.ylsk.check.service.IReportInfoService;
import com.ylsk.common.utils.poi.ExcelUtil;
import com.ylsk.common.core.page.TableDataInfo;

/**
 * 报备信息Controller
 *
 * @author yangsy
 * @date 2023-12-13
 */
@RestController
@RequestMapping("/check/reportInfo")
public class ReportInfoController extends BaseController
{
    @Autowired
    private IReportInfoService reportInfoService;

    /**
     * 查询报备信息列表
     */
    @PreAuthorize("@ss.hasPermi('check:reportInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReportInfoSO reportInfoSO)
    {
        startPage();
        List<ReportInfoVO> list = reportInfoService.selectreportInfoList(reportInfoSO);
        return getDataTable(list);
    }

    /**
     * 导出报备信息列表
     */
    @PreAuthorize("@ss.hasPermi('check:reportInfo:export')")
    @Log(title = "报备信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReportInfoSO reportInfoSO)
    {
        List<ReportInfoVO> list = reportInfoService.selectreportInfoList(reportInfoSO);
        ExcelUtil<ReportInfoVO> util = new ExcelUtil<ReportInfoVO>(ReportInfoVO.class);
        util.exportExcel(response, list, "报备信息数据");
    }

    /**
     * 获取报备信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('check:reportInfo:query')")
    @GetMapping(value = "/{reportInfoId}")
    public AjaxResult getInfo(@PathVariable("reportInfoId") Long reportInfoId)
    {
        return success(reportInfoService.selectreportInfoByreportInfoId(reportInfoId));
    }

    /**
     * 新增报备信息
     */
    @PreAuthorize("@ss.hasPermi('check:reportInfo:add')")
    @Log(title = "报备信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReportInfoDTO reportInfoDTO)
    {
        return toAjax(reportInfoService.insertreportInfo(reportInfoDTO));
    }

    /**
     * 修改报备信息
     */
    @PreAuthorize("@ss.hasPermi('check:reportInfo:edit')")
    @Log(title = "报备信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReportInfoDTO reportInfoDTO)
    {
        return toAjax(reportInfoService.updatereportInfo(reportInfoDTO));
    }

    /**
     * 删除报备信息
     */
    @PreAuthorize("@ss.hasPermi('check:reportInfo:remove')")
    @Log(title = "报备信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reportInfoIds}")
    public AjaxResult remove(@PathVariable Long[] reportInfoIds)
    {
        return toAjax(reportInfoService.deletereportInfoByreportInfoIds(reportInfoIds));
    }

    /**
     * 查询报备信息不分页列表
     */
    @GetMapping("/selectList")
    public AjaxResult selectList(ReportInfoSO reportInfoSO)
    {
        List<ReportInfoVO> list = reportInfoService.selectreportInfoList(reportInfoSO);
        return success(list);
    }
}
